﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Coding4Fun.Phone.Controls;

namespace DSA
{
    public partial class ShoppingListEntryItem : UserControl
    {
        public bool NameChanged = false;

        public ShoppingListEntryItem()
        {
            InitializeComponent();
        }

        private void RenameItemClick(object sender, EventArgs e)
        {
            // If selected index is -1 (no selection) do nothing
            //if (listBoxMain.SelectedIndex == -1)
            //    return;

            InputPrompt input = new InputPrompt();
            input.Completed += Rename_Completed;
            input.Title = "Rename List";
            input.Message = "New name for this list";
            input.Show();
        }

        private void Rename_Completed(object sender, PopUpEventArgs<string, PopUpResult> e)
        {
            if (e.PopUpResult == PopUpResult.Ok && !String.IsNullOrEmpty(e.Result))
            {
                this.ListName.Text = e.Result;
                NameChanged = true;
            }
        }

        private void DeleteClick(object sender, EventArgs e)
        {
            PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
            MainPage pg = frame.Content as MainPage;

            pg.listBoxMain.Items.Remove(this);
        }
    }
}
